from interface.MemberInterface import MemberInterface
from utils.SendMethod import SendMethod


class AddressInterface:
    def __init__(self, url):
        self.url = url

    # 添加收获地址
    def add_address(self, login_payload, payload):
        # 获取token
        token = MemberInterface(self.url).get_member_token(login_payload)
        # 发送生成订单请求,获得响应数据
        url = self.url + '/member/address/add'
        return SendMethod.send_method('post', url=url, headers=token, json=payload)


if __name__ == '__main__':
    url = 'http://47.108.206.100:8085'
    login_payload = {
        'username': 'yyn1234',
        'password': '12345678'
    }
    payload = {
        "city": "武汉",
        "defaultStatus": 1,
        "detailAddress": "江夏",
        "id": 0,
        "memberId": 0,
        "name": "杨宇",
        "phoneNumber": "12345678911",
        "postCode": "113",
        "province": "湖北",
        "region": "谷尚居"
    }
    print(AddressInterface(url).add_address(login_payload=login_payload, payload=payload))
